import defaultAvatar from '@/assets/default_avatar.jpg'
import store from '@/store'

export function chatListAppendUser(item) {
  const result = { ...item }
  result.user = store.getters.getUserById(result.right_id)
  if (result.user) {
    result.user.avatar_url = result.user.avatar_url || defaultAvatar
    return result
  } else {
    result.user = {
      avatar: null,
      avatar_url: null,
      id: 0,
      is_active: false,
      is_superadmin: false,
      last_login_at: 0,
      realname: '<已注销>',
      register_at: 0,
      role: 0,
      username: '<已注销>'
    }
    return result
  }
}

export function contactListFixAvatar(item) {
  const result = { ...item }
  result.avatar_url = result.avatar_url || defaultAvatar
  return result
}
